package chapter4.No4_1_使用reentrantLock类.demo14;

import java.util.concurrent.locks.ReentrantLock;

/**
 * Created by Administrator on 2016/11/22.
 */
public class ServiceClass {
    ReentrantLock lock;

    public ServiceClass(boolean isFair) {
        this.lock = new ReentrantLock(isFair);
    }

    public void methodA() {
        lock.lock();
        System.out.println("线程" + Thread.currentThread().getName() + "是否是公平锁：" + lock.isFair());
        lock.unlock();
    }
}
